#include "Rectangle.h"
#include <math.h>

Rectangle::Rectangle(double width, double height){
    m_width=trunc(width*100)/100;
    m_height=trunc(height*100)/100;
};
   
bool Rectangle::isHeightValid(const double value ) const {	
    return ((value > 0)&&(value < MAXIMUM_HEIGHT));
}
   
bool Rectangle::isWidthValid(const double value ) const {	
    return ((value > 0)&&(value < MAXIMUM_WIDTH));
}

bool Rectangle::isRectangleValid() const{
    return (isHeightValid(m_height)&&isWidthValid(m_width));
}
double Rectangle::getArea() const {
    return isRectangleValid()?round(m_width*m_height*100)/100:0;
}
   
double Rectangle::getPerimeter() const {
    return isRectangleValid()?round((m_width + m_height)*2*100)/100:0;
}

void Rectangle::setWidth(double width){
    if(isWidthValid(width))
        m_width=trunc(width*100)/100;  
}

void Rectangle::setHeight(double height){
    if(isHeightValid(height))
        m_height=trunc(height*100)/100;
}
	
